<template>
        <el-card shadow="never" style="max-height: 700px; overflow: auto">
            <el-form ref="form" :model="form" :rules="rules" label-width="90px" :disabled="disabled">
                <el-form-item label="id:" prop="id" v-show="false">
                    <el-input v-model="form.id" disabled />
                </el-form-item>
                <el-form-item label="添加时间:" prop="createtime">
                    <el-date-picker v-model="form.createtime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择添加时间" />
                </el-form-item>    

                <el-form-item label="更新时间:" prop="updatetime">
                    <el-date-picker v-model="form.updatetime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择更新时间" />
                </el-form-item>        

                <el-form-item label="状态:" prop="status">
                    <el-input v-model="form.status" placeholder="请输入状态" clearable />
                </el-form-item>
                <el-form-item label="运费（人民币）:" prop="freight">
                    <el-input-number v-model="form.freight" :step="0.001" :min="0"></el-input-number>
                </el-form-item>
                <el-form-item label="运费（美金）:" prop="freightmj">
                    <el-input-number v-model="form.freightmj" :step="0.001" :min="0"></el-input-number>
                </el-form-item>
                <el-form-item label="采购成本（美金）:" prop="material">
                    <el-input-number v-model="form.material" :step="0.001" :min="0"></el-input-number>
                </el-form-item>
                <el-form-item label="备注:" prop="content">
                    <el-input v-model="form.content" placeholder="请输入备注" :rows="4" type="textarea" />
                </el-form-item>       
                <el-form-item label="总成本:" prop="zcost">
                    <el-input-number v-model="form.zcost" :step="0.001" :min="0"></el-input-number>
                </el-form-item>
                <el-form-item label="总毛利:" prop="gross_profit">
                    <el-input-number v-model="form.gross_profit" :step="0.001" :min="0"></el-input-number>
                </el-form-item>
                <el-form-item label="订单时间:" prop="timedate">
                    <el-date-picker v-model="form.timedate" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择订单时间" />
                </el-form-item>        

                <el-form-item label="商品金额:" prop="total_price">
                    <el-input-number v-model="form.total_price" :step="0.001" :min="0"></el-input-number>
                </el-form-item>
                <el-form-item label="advertisingz:" prop="advertisingz">
                    <el-input-number v-model="form.advertisingz" :step="0.001" :min="0"></el-input-number>
                </el-form-item>
                <el-form-item label="salesz:" prop="salesz">
                    <el-input-number v-model="form.salesz" :step="0.001" :min="0"></el-input-number>
                </el-form-item>
                <el-form-item label="店铺管理者:" prop="admin_id">
                    <el-input-number v-model="form.admin_id" :step="1" :min="0"></el-input-number>
                </el-form-item>
                <el-form-item label="店铺:" prop="accounturl">
                    <el-input-number v-model="form.accounturl" :step="1" :min="0"></el-input-number>
                </el-form-item>
                <el-form-item label="总销售额($)(95%):" prop="salesz_discount">
                    <el-input-number v-model="form.salesz_discount" :step="0.001" :min="0"></el-input-number>
                </el-form-item>
                <el-form-item label="info:" prop="info">
                    <el-input v-model="form.info" placeholder="请输入info" clearable />
                </el-form-item>
                <el-form-item label="原金额:" prop="saleszy">
                    <el-input-number v-model="form.saleszy" :step="0.001" :min="0"></el-input-number>
                </el-form-item>
                <el-form-item label="小费:" prop="total_tip_received">
                    <el-input-number v-model="form.total_tip_received" :step="0.001" :min="0"></el-input-number>
                </el-form-item>

                <el-form-item>
                    <el-button type="primary" @click="submitForm">确认 </el-button>
                    <el-button type="warning" @click="cancel">取消 </el-button>
                </el-form-item>
            </el-form>
        </el-card>
</template>

<script>
export default {
    name: 'EditForm',
    props: {
        findFormData: {
            type: Object,
            default: {}
        },
        editFormParams: {
            type: Object,
            default: {}
        },
        // 表单是否禁用
        disabled: {
            type: Boolean,
            default: false,
        },
        
    },
    data() {
        return {
            // 编辑表单验证规则
            rules: {
        
            },
            form: {  },
          

        }
    },
    watch: {
        findFormData: {
           handler(nval) {
                if (JSON.stringify(nval) != '{}') {
                    this.$nextTick(() => {
                        this.form = nval
                    })
                }
            },
            immediate: true,
            deep: false,
        },
        
    },
    methods: {
        // 取消按钮
        cancel() {
            this.$emit('editFormCancel')
        },

        submitForm() {
            this.$refs['form'].validate((valid, obj) => {
                if (valid) {
                    this.$emit('submitForm', this.form)
                }
            })
        },

        // 表单重置
        reset() {
            this.resetForm('form')
        }
    }
}
</script>
